<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> UDT Reference</title>
<link rel="stylesheet" href="udtdoc.css" type="text/css" />
</head>

<body>
<div class="ref_head">&nbsp;UDT Reference: Functions</div>

<h4 class="func_name"><strong>send</strong></h4>
<p>The <b>send</b> method sends out certain amount of data from an application buffer.</p>

<div class="code">int send(<br />
&nbsp; UDTSOCKET <font color="#FFFFFF">u</font>,<br />
&nbsp; const char* <font color="#FFFFFF">buf</font>,<br />
&nbsp; int <font color="#FFFFFF">len</font>,<br />
&nbsp; int <font color="#FFFFFF">flags</font><br />
);</div>

<h5>Parameters</h5>
<dl>
  <dt><i>u</i></dt>
  <dd>[in] Descriptor identifying a connected socket.</dd>
  <dt><em>buf</em></dt>
  <dd>[in] The buffer of data to be sent.</dd>
  <dt><em>len</em></dt>
  <dd>[in] Length of the buffer.</dd>
  <dt><em>flags</em></dt>
  <dd>[in] Ignored. For compatibility only.</dd>
</dl>

<h5>Return Value</h5>
<p>On success, <b>send</b> returns the actual size of data that has been sent. Otherwise UDT::ERROR is returned and specific error information can be retrieved by <a 
href="error.htm">getlasterror</a>. If UDT_SNDTIMEO is set to a positive value, zero will be returned if no data is sent before the timer expires.</p>

<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
  <tr>
    <td width="17%" class="table_headline"><strong>Error Name</strong></td>
    <td width="17%" class="table_headline"><strong>Error Code</strong></td>
    <td width="83%" class="table_headline"><strong>Comment</strong></td>
  </tr>
  <tr>
    <td>ECONNLOST</td>
    <td>2001</td>
    <td>connection has been broken.</td>
  </tr>
  <tr>
    <td>ENOCONN</td>
    <td>2002</td>
    <td><i>u</i> is not connected.</td>
  </tr>
  <tr>
    <td>EINVSOCK</td>
    <td>5004</td>
    <td><i>u</i> is not an valid socket.</td>
  </tr>
  <tr>
    <td>EDGRAMILL</td>
    <td>5010</td>
    <td>cannot use <i>send</i> in SOCK_DGRAM mode.</td>
  </tr>
  <tr>
    <td>EASYNCSND</td>
    <td>6001</td>
    <td><i>u</i> is non-blocking (UDT_SNDSYN = false) but buffer space is available for sending.</td>
  </tr>
  <tr>
    <td>ETIMEOUT</td>
    <td>6003</td>
    <td>Timeout on UDT_SNDTIMEO .</td>
  </tr>
  <tr>
    <td>EPEERERR</td>
    <td>7000</td>
    <td>The peer side has an unrecoverable error and this call has to be cancelled. </td>
  </tr>
</table>

<h5>Description</h5>
<p>The <strong>send</strong> method sends certain amount of data from the application buffer. If the the size limit of sending buffer queue is reached, 
<strong>send</strong> only sends a portion of the application buffer and returns the actual size of data that has been sent.</p>
<p>In blocking mode (default), <strong>send</strong> waits until there is some sending buffer space available. In non-blocking mode, <strong>send</strong> 
returns immediately and returns error if the sending queue limit is already limited.</p>
<p>If UDT_SNDTIMEO is set and the socket is in blocking mode, <strong>send</strong> only waits a limited time specified by UDT_SNDTIMEO option. If there is still no 
buffer space available when the timer expires, error will be returned. UDT_SNDTIMEO has no effect for non-blocking socket.</p>

<h5>See Also</h5>
<p><strong><a href="recv.htm">send</a>, <a href="sendfile.htm">sendfile</a>, <a href="recvfile.htm">recvfile</a></strong></p>
<p>&nbsp;</p>

</body>
</html>
